<template>
	<view>
		<view class="detail-box">
			<view class="cu-form-group">
				<view class="title">商品名称：</view>
				<input class="inpt" v-model="NowSelectGoods.GoodsName"  disabled="true" ></input>
				<!-- <button class="cu-btn round stop text-white" @tap="gogoodlist">查询</button> -->
			</view>
			<view class="cu-form-group">
				<view class="title">编　　号：</view>
				<input class="inpt" v-model="NowSelectGoods.GoodsID" disabled="true" ></input>
			</view>
			<view class="cu-form-group">
				<view class="title">规　　格：</view>
				<input class="inpt" disabled="true" v-model="NowSelectGoods.Spec"></input>
				<!-- <button class="cu-btn round stop text-white" @tap="showModal" data-target="Modal">查询</button> -->
			</view>
			<!-- v-if="orderType!=10" -->
			<view class="cu-form-group" @tap="clickselect(1,'仓库')">
				<view class="title">{{Isdistribution == 1?'配出仓库':'仓　　库'}}：</view>
				<input class="inpt" disabled="true"  :placeholder="Isdistribution == 1?'点击选择<配出仓库>':'点击选择<仓库>'" v-model="NowSelectGoods.StoreName"></input>
			</view>
			<view class="cu-form-group" v-if="Isdistribution == 1" @tap="clickselect(4,'配入仓库')">
				<view class="title">配入仓库：</view>
				<input class="inpt"  placeholder="点击选择<配入仓库>" v-model="NowSelectGoods.StoreName2"></input>
			</view>
			<view class="cu-form-group" @tap="clickselect(2,'单位')">
				<view class="title">单　　位：</view>
				<input class="inpt" disabled="true" v-model="NowSelectGoods.UnitName"  placeholder="点击选择<单位>"  ></input>
			</view>
			<!-- v-if="orderType==2" -->
			<view class="cu-form-group" @tap="clickselect(3,'赠品')" >
				<view class="title">赠　　品：</view>
				<input class="inpt" disabled="true" v-model="Giftname"  placeholder="点击选择<赠品>"  ></input>
			</view>
			<!-- v-show="orderType==10" -->
			
			
			<!-- <view class="cu-form-group" >
			<view class="title" >批　　号：</view>
			<input disabled="true" v-if="IsBatch == true" class="inpt" placeholder="请选择批号" v-model="NowSelectGoods.BatchNo" ></input>
			<input disabled="true" v-else class="inpt" placeholder="不可选择批号" ></input>
			<button class="cu-btn  stop text-white btn_color" v-if="IsBatch == true"  @tap="XHGetBatchNoFollow()">选择</button>
			</view> -->
			<view class="cu-form-group" >
				<view class="title">批　　号：
				</view>
				<input :disabled="!IsBatch" v-model="NowSelectGoods.BatchNo" @input="GetBatchNo" :placeholder="IsBatch==true?'请输入批号或者选择批号':'不是批号商品'"></input>
				<button class="cu-btn  stop text-white btn_color"  v-if="IsBatch==true"  @tap.stop="XHGetBatchNoFollow()">选择</button>
			</view>
			
			<view class="cu-form-group" @tap="open('QS_Picekr_date',0)">
				<view class="title">生产日期：</view>
				<!-- <view  class="inpt1"> -->
					<!-- :value="timesubstr(ProductionDate)" -->
					<input disabled="true" class="inpt"  v-model="ProductionDate" :placeholder="datePlaceHolder"></input>
				<!-- </view> -->
			</view>
			<view class="cu-form-group" @tap="open('QS_Picekr_date',1)">
				<view class="title">有效日期：</view>
				<!-- <view  class="inpt1"> -->
					<!-- :value="timesubstr(validityDate)" -->
					<input disabled="true" class="inpt" v-model="validityDate" :placeholder="datePlaceHolder"></input>
				<!-- </view> -->
			</view>
			<view class="cu-form-group">
				<view class="title">税　　率：</view>
				<input class="inpt" type="number" name="input"   placeholder="点击修改" v-model="NowSelectGoods.Tax" ></input>
			</view>
			<view class="cu-form-group">
				<view class="title">单　　价：</view>
				<input class="inpt" type="number" name="input" maxlength="7" placeholder="点击修改" v-model="NowSelectGoods.Price" ></input>
				<button class="cu-btn  stop text-white btn_color"   @tap="clickselect(5,'单价')">选择</button>
			</view>
			<view class="cu-form-group">
				<view class="title">折　　扣：</view>
				<input class="inpt" type="number" name="input"  placeholder="点击修改" v-model="NowSelectGoods.Discount" ></input>
			</view>
		<!-- 	<view class="cu-form-group">
				<view class="title">批号：</view>
				<input class="inpt" name="input" disabled="true" ></input> -->
				<!-- <button class="cu-btn round stop text-white" @tap="showModal" data-target="Modal">查询</button> -->
		<!-- 	</view> -->
			<view class="cu-form-group">
				<view class="title">数　　量：</view>
				<!-- <input class="inpt" name="input" placeholder="点击修改" v-model="NowSelecty" ></input> -->
				<input class="inpt" type="number" maxlength="5" name="input" placeholder="点击修改" v-model="NowSelectGoods.Qty" ></input>
			</view>
			<view class="cu-form-group">
				<view class="title">库　　存：</view>
				<input class="inpt" name="input" disabled="true" :value="NowSelectGoods.stockqty"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">备　　注：</view>
				<input class="inpt" name="input" placeholder="请输入备注" v-model="NowSelectGoods.Remark" ></input>
			</view>
			<view class="cu-form-group">
				<!-- <button class="cu-btn  stop text-white" @tap="AddBillOrder">提交修改</button> -->
				<input class="inpt" name="input" disabled="true"></input>
				<button class="cu-btn  stop text-white btn_color" @tap="addSelectGoods">提交修改</button>
			</view>
		</view>
		<!-- 选择批号 -->
		<view class="cu-modal " :class="isShowScanModel?'show':''">
			<view class="cu-dialog ls-main">
				<view class="cu-bar bg-ls justify-between">
					<view class="action">
						<view class="cuIcon-info text-white" v-show="false"></view>
					</view>
					<view class="content text-white btn_title">选择批号</view>
					<view class="action" @tap="hideModal">
						<text class="cuIcon-close text-white btn_title"></text>
					</view>
				</view>
				<view class="padding text-left bg-white ls-contain">
					<scroll-view scroll-y style="height: 400px;padding-bottom: 100px">
						<view class="ls-box" @tap="choosesGoods(index)" v-for="(item,index) in storeList" :key='index' :data-index="index">
							<!-- <view class="text-black">数据库：</view> -->
							<view>批次号:{{item.FBatchNo}}</view>
						</view>
					</scroll-view>
				</view>
			</view>
		</view>
		<!-- <uni-calendar ref="calendar1" :insert="false" @confirm="confirm1" />
		<uni-calendar ref="calendar2" :insert="false" @confirm="confirm2" /> -->
		<!-- 统一弹出框HOME -->
		<view class="cu-modal cu_none " :class="modalName=='Modal'?'show':''">
			<view class="cu-dialog" :class="[{'new-cu-dialog':listshow == 3}]" >
				<view class="cu-bar bg-white justify-end">
					<view class="content">选择{{listcode}}</view>
					<view class="action" @tap="hideModal">
						<text class="cuIcon-close text-red"></text>
					</view>
				</view>
				<scroll-view style="height: 90%;" scroll-y="true">
				<view class="padding-xl" v-show="listshow == 1">
					<view class="search" ><input class="inpt" v-model="selectwar" 
					 :placeholder="Isdistribution==1?'查询配出仓库':'查询仓库'" name="input"></input>
					<span class="search_span" @tap="selectClient()">搜索</span>
					</view>
					<view>
						<view class="btn_list"  v-for="(item,index) in stolist" 
						 @tap="checkuser(index)" :key="item.id">{{item.StoreName}}</view>	
						 <!-- //StoreID		 -->
					</view>
				</view>
				<view class="padding-xl" v-show="listshow == 2">
					<view class="search" ><input class="inpt" v-model="selectpic" placeholder="查询单位" name="input"></input>
					<span class="search_span"  @tap="selectwarehouse()">搜索</span>
					</view>
					<view>
						<view class="btn_list"  v-for="(item,index) in GoodsUnit" 
						 @tap="checkware(index)" :key="item.id">{{item.UnitName}}</view>			
					</view>
				</view>
				<view class="padding-xl" v-show="listshow == 3">
						<view class="btn_list newbtn_list" style="padding-bottom: 10px;"  v-for="(item,index) in isgift " 
						 @tap="isgifts(index)" :key="item.id">{{item.name}}</view>			
				</view>
				<view class="padding-xl" v-show="listshow == 4">
					<view class="search" ><input class="inpt" v-model="selectpic" placeholder="查询单位" name="input"></input>
					<span class="search_span"  @tap="selectwarehouse()">搜索</span>
					</view>
					<view>
						<view class="btn_list"  v-for="(item,index) in warehouse" 
						 @tap="checkput(index)" :key="item.id">{{item.StoreName}}</view>			
					</view>
				</view>
				<view class="padding-xl" v-show="listshow == 5">
					<view>
						<view class="btn_list"  v-for="(item,index) in PricrList" 
						 @tap="checkprice(index)" :key="item.id">{{item.ShowValue}}</view>			
					</view>
				</view>
				</scroll-view>
			</view>
		</view>
		<!-- 统一弹出框END -->
		<QSpicker title="请选择日期时间" mode="bottom" type="date" ref="QS_Picekr_date" pickerId="date_1" :dataSet="dateSet"
		 showReset :autoHide="false" contentColor="#33cc33" :lineHeight=".05" @hideQSPicker="hideQSPicker($event)"
		 @showQSPicker="showQSPicker($event)" @confirm="confirm($event)" />
	</view>
</template>
<script>
	import * as Api from '@/syApis/syAddOrder/syaddApis.js';
	// import uniCalendar from '@/components/uni-calendar/uni-calendar.vue';
	import QSpicker from '@/components/QuShe-picker/QuShe-picker.vue';
	import * as GetApi from '@/syApis/syHttp/Http.js';
	export default {
		name:'goodInfoDetail',
		data() {
			return {
				//选择的商品
				NowSelectGoods: {
					ProductionDate:'',
					validityDate:'',
					StoreName2:''
				},
				//添加的备注
				GoodsRemark: "",
				//商品库存
				GoodsStorm: 0,
				//商品税率
				Tax: 0,
				selectpic:'',// 搜索单价
				selectwar:'',// 搜索的仓库
				//商品
				GoodsQty: 0,
				//商品折扣
				GoodsDiscount: "",
				//仓库ID
				// StoreID: "",
				isgift:[{
					name:'否'
				},{
					name:'是'
				}],
				SelectStockNum:"",
				storeList:[],
				GoodsUnit:[],//多单位
				stolist:[],
				warehouse:[],//配入仓库
				modalName:'',
				//生产日期
				ProductionDate:"",
				//有效日期
				validityDate:"",
				// isgift: ['否','是'],
				IsBatch:null,
				Inventorybatch:"",
				listcode:'',
				isShowScanModel:false,
				//日期palceholde
				datePlaceHolder:"点击选择日期",
				NowSelecty:0,
				listshow:-1,
				Giftindex:0,
				Giftname:'',
				Isdistribution:0,//是否是  配送订单
				PricrList:[],
				isdata:null,
				dateSet: {
					dateMode: 3,
					dateFormatArray: ['-', '-', ' ', ':', ':']
				},
				BillName:'',
				ClientID:""
			}
		},
		created() {
			this.GetStoreMessage();
		},
		onLoad(options) {
			console.log(options);
			this.NowSelectGoods = JSON.parse(options.goodData);
			console.log(this.NowSelectGoods)
			this.NowSelectGoods.BatchNo = this.NowSelectGoods.BatchNo || "";
			this.StoreID = options.StoreID;
			this.index = options.selectIndex;
			this.Isdistribution = options.Isdistribution
			this.IsBatch = this.NowSelectGoods.IsBatch;
			this.BillName = options.name;
			this.ProductionDate = this.NowSelectGoods.ProductionDate == undefined?"":this.NowSelectGoods.ProductionDate 
			this.validityDate = this.NowSelectGoods.validityDate == undefined?"":this.NowSelectGoods.validityDate 
			this.ClientID = options.ClientID;
			// console.log(this.index)
			this.Inventorybatch = options.Inventorybatch;
			if(this.IsBatch==true){
				this.datePlaceHolder = "点击选择日期"
			}else{
				this.datePlaceHolder = "不可选择日期"
			}
			this.getGoodsUnitMessage();
			this.prices();
			this.Giftname = this.isgift[this.Giftindex].name//初始化赋值 赠品
			console.log('初始化成功!')
			console.log(this.Giftname)
			// this.SelectStockNum(this.NowSelectGoods.GoodsID);
			
		},
		components: {
			// uniCalendar
			QSpicker,
		},
		watch:{ 
			// 数量不能超过10000
			NowSelectGoods:{
				handler:(values)=> {
					console.log(values.Qty)
					// console.log(values)
					if(values.Qty>10000){
						Api.showTip('数量不能超过10000');
					}
				},
				deep:true
			},
		},
		methods: {
			//获取批号
			XHGetBatchNoFollow(){
				// NowSelectGoods
				var that = this;
				let data = {
					StoreID:this.StoreID,//this.StoreID
					// GoodsID:this.NowSelectGoods.GoodsID,
					BillName:this.BillName,
					// Inventorybatch:this.Inventorybatch  
				};
				//如果是批号商品则添加
				// if(that.NowSelectGoods.IsBatch == true){
					data["GoodsID"]=this.NowSelectGoods.GoodsID
				// }
				// console.log(data)
				// return
				Api.XHGetBatchNoFollow(data,function(res){
					if(res.state){
						if(res.data.ErrorMsg=='获取登录信息失败'){
							
						}else if(res.data.ErrorMsg!=''){
							Api.showTip(res.data.ErrorMsg);
						}else{
							// that.storeList = res.data.ResultMsg;
							var storeLists = []
							// that.storeList = that.timesubstr(that.storeList["FDate"])FValidDate
							for(var i in res.data.ResultMsg){
								if(res.data.ResultMsg[i]["FBatchNo"]!=""){
									storeLists.push(res.data.ResultMsg[i])
								}
							}
							console.log(storeLists)
							if(storeLists.length>0){
								that.isShowScanModel = true;
								that.storeList = storeLists
							}else{
								Api.showTip('查无批号');
							}
						}
					}
				})
			},
			// 点击打开弹框
			clickselect:function(evt,msg){
				var that = this;
				that.modalName = 'Modal'
				that.listshow = evt
				that.listcode = that.Isdistribution == 1 && evt== 1?'配出仓库':msg
			},
			isgifts:function(index){
				this.Giftindex = index
				this.Giftname = this.isgift[index].name
				console.log(this.Giftindex)
				this.modalName = null
			},
			//选中的仓库
			checkuser:function(index){
				this.NowSelectGoods.StoreName = this.stolist[index]["StoreName"]
				this.NowSelectGoods.StoreID = this.stolist[index]["StoreID"]
				console.log('选择仓库后的参数')
				console.log(this.NowSelectGoods)
				//获取仓库的库存
				this.GetStoreNum()
				this.modalName = null
			},
			//选中的单位
			checkware:function(index){
				this.NowSelectGoods.UnitName = this.GoodsUnit[index]["UnitName"]
				this.NowSelectGoods.UnitID = this.GoodsUnit[index]["UnitID"]
				this.NowSelectGoods.urate = this.GoodsUnit[index]["urate"]
				this.modalName = null
				this.prices()
			},
			//选中的配入仓库
			checkput:function(index){
				this.NowSelectGoods.StoreName2 = this.warehouse[index]["StoreName"]
				this.NowSelectGoods.StoreID2 = this.warehouse[index]["StoreID"]
				this.modalName = null
			},
			//选中的单价
			checkprice:function(index){
				this.NowSelectGoods.Price = parseFloat(this.PricrList[index]["Price"])
				this.modalName = null
			},
			hideModal(e) {
				//console.log(222)
				this.modalName = null
				this.isShowScanModel =null
			},
			
			choosesGoods(index){
				this.ProductionDate = this.timesubstr(this.storeList[index].FDate);
				this.validityDate = this.timesubstr(this.storeList[index].FValidDate);
				this.NowSelectGoods.ProductionDate = this.timesubstr(this.storeList[index].FDate);
				this.NowSelectGoods.validityDate =  this.timesubstr(this.storeList[index].FValidDate);
				this.NowSelectGoods.BatchNo =  this.storeList[index].FBatchNo;
				this.NowSelectGoods.stockqty = parseFloat(this.storeList[index].FQty);
				this.isShowScanModel = false;
				console.log(this.NowSelectGoods);
			},
            GetStoreNum:function(){
				let data = {
					StoreID: this.NowSelectGoods.StoreID,
					GoodsID: this.NowSelectGoods.GoodsID,
					BillName: this.BillName
				};
				var _this = this;
				GetApi.Select_StockNum(data, (res) => {
					if (res.data.ErrorMsg == "获取登录信息失败") {
				        // console.log('获取登陆信息失败')
						GetApi.showTip('获取登录信息失败');
					} else if (res.data.ErrorMsg != "") {
						GetApi.showTip(res.data.ErrorMsg);
					} else {
						// _this.GoodsStorm = res.data.ResultMsg;
						_this.NowSelectGoods.stockqty = res.data.ResultMsg;
					}
				});
			},
			// open1() {
			// 	if(this.IsBatch==true){
			// 		this.$refs.calendar1.open();
			// 	}
			// },
			// open2() {
			// 	if(this.IsBatch==true){
			// 		this.$refs.calendar2.open();
			// 	}
			// },
			open(name, type) {
				if(this.IsBatch==true){
					this.isdata = type;//赋值给isdata用于判断是开始日期还是结束日期
					this.$refs[name].show();
					this.dateName = name;
				}
			},
			confirm(res) {
				var data = GetApi.splitdate(res.data);//处理的日期
				console.log(data)
				// 1是开始日期 2是结束日期
				if(this.isdata == 0){
					// console.log(e)
					// this.timeData.fulldate = data
					this.ProductionDate = data
					this.NowSelectGoods.ProductionDate = data
					this.validityDate = this.DateToTime(data,0,this.NowSelectGoods.Days);
					this.NowSelectGoods.validityDate = this.DateToTime(data,0,this.NowSelectGoods.Days);
				}else if(this.isdata == 1){
					// this.timeData1.fulldate = data
					this.validityDate = data
					this.NowSelectGoods.validityDate = data
					this.ProductionDate = this.DateToTime(data,1,this.NowSelectGoods.Days);
					this.NowSelectGoods.ProductionDate = this.DateToTime(data,1,this.NowSelectGoods.Days);
				}
				this.$refs[this.dateName].hide();
				console.log('执行了时间')
				console.log(this.NowSelectGoods)
				console.log('开始时间-----------')
				console.log(this.ProductionDate)
				console.log('结束时间')
				console.log(this.validityDate)
			},
			showQSPicker(res) {
				console.log(res);
			},
			hideQSPicker(res) {
			
			},
			// confirm1(e) {
			// 	// var fulldate = e.detail.fulldate
			// 	// console.log(e.detail.fulldate);
			// 	var that = this;
			// 	console.log(e.fulldate)
			// 	that.ProductionDate = this.timesubstr(e.fulldate);
			// 	that.NowSelectGoods["ProductionDate"] = e.fulldate;
			// 	console.log('这是一个打印的值')
				
			// 	console.log(that.NowSelectGoods.ProductionDate)
			// },
			// confirm2(e) {
			// 	// var fulldate = e.detail.fulldate
			// 	// console.log(e.detail.fulldate);
			// 	console.log(e)
			// 	this.validityDate = this.timesubstr(e.fulldate),
			// 	this.NowSelectGoods.validityDate = e.fulldate;
			// },
			//获取仓库
			GetStoreMessage() {
				let data = {
					Filter: ""
				}
				var that = this;
				Api.GetStoreMessage(data, function(res) {
					if (res.state) {
						if (res.data.ErrorMsg == "获取登录信息失败") {
							Api.showTip("登录超时");
						} else if (res.data.ErrorMsg != "") {
							Api.showTip(res.data.ErrorMsg);
						} else {
							// let responseData = res.data.ResultMsg;
							that.stolist = res.data.ResultMsg;
							that.warehouse=res.data.ResultMsg;
							console.log('这是单据')
							console.log(that.NowSelectGoods)
							console.log('这是获取的仓库')
							console.log(res.data.ResultMsg)
							
							// that.NowSelectGoods.StoreID = res.data.ResultMsg[0].BranchID;
							// that.stolist.forEach((item, index) => {
							// 	if(that.StoreID == item.StoreID){
							// 		that.NowSelectGoods.StoreID = item.StoreID
							// 		that.NowSelectGoods.StoreName = item.StoreName
							// 		// return true
							// 	}
							// 	if(that.Isdistribution == 1){
							// 		if(that.NowSelectGoods.StoreID2 == item.StoreID){
							// 			that.NowSelectGoods.StoreID2 = item.StoreID
							// 			that.NowSelectGoods.StoreName2 = item.StoreName
										
							// 		}
							// 	}
							
							// });
							console.log('表头仓库')
							console.log(that.NowSelectGoods.StoreID)
							for(var i in that.stolist){
								
								if(that.NowSelectGoods.StoreID != undefined){
									if(that.NowSelectGoods.StoreID == that.stolist[i].StoreID){
										that.NowSelectGoods.StoreID = that.stolist[i].StoreID
										that.NowSelectGoods.StoreName = that.stolist[i].StoreName
										// return true
									}
								}else{
									if(that.StoreID == that.stolist[i].StoreID){
										that.NowSelectGoods.StoreID = that.stolist[i].StoreID
										that.NowSelectGoods.StoreName = that.stolist[i].StoreName
										// return true
									}
								}
								
								if(that.Isdistribution == "1"){
									// console.log('仓库id')
									// console.log(that.stolist[i].StoreID)
									// console.log(that.NowSelectGoods.StoreID2,that.stolist[i].StoreID)
									if(that.NowSelectGoods.StoreID2 == that.stolist[i].StoreID){
										// console.log('等于了--------------------')
										that.NowSelectGoods.StoreID2 = that.stolist[i].StoreID
										that.NowSelectGoods.StoreName2 = that.stolist[i].StoreName
										
									}
								}
							}
							console.log(that.NowSelectGoods)
						}
					} else {
			                 Api.showTip("服务器错误!");
					}
				});
			},
			//价格跟踪
			prices:function(){
				let data = {
					// this.NowSelectGoods
					ClientID :this.ClientID,
					StoreID:this.StoreID,
					BillName: this.BillName,
					GoodsID:this.NowSelectGoods.GoodsID,
					UnitID:this.NowSelectGoods.UnitID,
					URate:this.NowSelectGoods.urate,
					// VIPID:''
				} 
				var that = this;
				Api.XH_Get_PriceFollowMessage(data, function(res) {
					if (res.state) {
						if (res.data.ErrorMsg == "获取登录信息失败") {
							Api.showTip("登录超时");
						} else if (res.data.ErrorMsg != "") {
							Api.showTip(res.data.ErrorMsg);
						} else {
							
							that.NowSelectGoods["Price"]=parseFloat(res.data.ResultMsg[0]["Price"])
							that.PricrList = res.data.ResultMsg
						   console.log(res.data.ResultMsg[0]["Price"])
						}
					} else {
							Api.showTip("服务器错误!");
					}
				});
			},
			// 获取多单位
			getGoodsUnitMessage:function(){
				var that = this;
				let data = {
					GoodsID:this.NowSelectGoods.GoodsID,
				}
				Api.Get_GoodsUnitMessage(data, function(res) {
					if (res.state) {
						if (res.data.ErrorMsg == "获取登录信息失败") {
							Api.showTip("登录超时");
						} else if (res.data.ErrorMsg != "") {
							Api.showTip(res.data.ErrorMsg);
						} else {
							that.GoodsUnit = res.data.ResultMsg;
						}
					} else {
							Api.showTip("服务器错误!");
					}
				});
			},
			// inputTax:function(e){
			// 	console.log(e)
			// 	var ff = "16545.00"
			// 	console.log(ff.indexOf("."))
			// 	console.log(ff.indexOf(".") != -1 ); // true
			// 	// this.NowSelectGoods.Tax = e.detail.value.replace(/[^\d]/g,'')
			// 	// this.$set(this.NowSelectGoods, 'Tax', e.detail.value.replace(/[^\d]/g,'')); //起作用 
			//  // this.val=e.target.value.replace(/[^\d]/g,'');
			// },
			indexOfs:function(e){
				var str = "'"+e+"'"
				console.log('是否包含小数')
				console.log(str)
				console.log(str.indexOf(".") != -1)
				return str.indexOf(".") != -1
			},
			//获取当前选择的商品
			addSelectGoods(){
				this.NowSelectGoods.IsGift  = this.Giftindex;
				//计算金额
				this.NowSelectGoods.Amount = this.computPrice(this.NowSelectGoods)
				if(this.NowSelectGoods.Amount>1000000){
					Api.showTip("价格不能超过100万");
					return
				}
				if(this.IsBatch == true){
					if(this.NowSelectGoods.BatchNo == "" || this.NowSelectGoods.BatchNo == undefined){
						Api.showTip("请选择批号!");
						return
					}
				}
				
				if(this.NowSelectGoods.Qty ==0 || this.NowSelectGoods.Qty == undefined){
					// Api.showTip("商品数量不能少于一件!");
					uni.showToast({
						title:'商品数量不能少于一件!',
						icon:'none'
					})
					return
				}
				if(this.indexOfs(this.NowSelectGoods.Tax)){
					uni.showToast({
						title:'税率不能包含小数!',
						icon:'none'
					})
					return
				}
				console.log('点击了')
				if(this.indexOfs(this.NowSelectGoods.Discount)){
					uni.showToast({
						title:'折扣不能包含小数!',
						icon:'none'
					})
					return
				}
				console.log('点击了提交修改')
				// return
				this.NowSelectGoods.GoodsStorm = this.GoodsStorm;
				console.log(this.NowSelectGoods);
				// return
				// return
				let data = {
					
				};
				data.index = this.index;
				data.NewGoodInfo = JSON.stringify(this.NowSelectGoods);
				console.log("----");
				console.log(this.NowSelectGoods);
				// return;
				this.$eventHub.$emit('GoodStting', data);
				uni.navigateBack({
					delta:1
				})
			},
			//计算折扣后商品价格
			computPrice(item){
				// Price
				let Prices=0;
				Prices = item.Price*item.Qty*(item.Discount/100)*(1+item.Tax/100);
				return parseFloat(Prices).toFixed(2);
			},
			// 日期截取
			timesubstr:function(e){
				return e == ''|| e == undefined?'':e.substring(0,10)
			},
			GetBatchNo: function(e) {
					console.log('输入的值')
			
					var val = e.detail.value
					console.log(val)
					console.log(this.storeList)
					// this.storeList
					var stutas = false;
					var index = i;
					for (var i in this.storeList) {
						if (this.storeList[i]["FBatchNo"] == val) {
							stutas = true
							index = i
							break
						}
					}
					if (stutas == true) {
						this.ProductionDate = this.timesubstr(this.storeList[index].FDate);
						this.validityDate = this.timesubstr(this.storeList[index].FValidDate);
						this.NowSelectGoods.ProductionDate = this.storeList[index].FDate;
						this.NowSelectGoods.validityDate = this.storeList[index].FValidDate;
						this.NowSelectGoods.BatchNo = this.storeList[index].FBatchNo;
						this.NowSelectGoods.stockqty = parseFloat(this.storeList[index].FQty);
					} else {
						let date = new Date();
						var newdate = GetApi.splitdate(date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate());
						this.ProductionDate = newdate;
						this.validityDate = this.DateToTime(newdate,0,'30');
						this.NowSelectGoods.ProductionDate = newdate;
						this.NowSelectGoods.validityDate = this.DateToTime(newdate,0,'30');
						this.NowSelectGoods.BatchNo = val;
						this.NowSelectGoods.stockqty = 0;
					}
				},
				// console.log('时间')
				// console.log(date)
				
				// 1.时间,2.(0是加,1是减),3.有效天数
				DateToTime: function(e,count, num) {
					console.log('时间',e,'加减',count,'有效天数',num)
					var date = new Date(e);
					var time = Date.parse(date);
					// var dates = Math.round(time / 1000) - 2592000;
					var dates = Math.round(time / 1000);
					// console.log('转换成功')
					var times = null
					if (count == 0) {
						times = (dates + (60 * 60 * 24 * (Number(num))))
					} else if (count == 1) {
						times = (dates - (60 * 60 * 24 * (Number(num))))
					}
					var datess = new Date(Math.round(times * 1000));
					var YY = datess.getFullYear() + '-';
					var MM = (datess.getMonth() + 1 < 10 ? '0' + (datess.getMonth() + 1) : datess.getMonth() + 1) + '-';
					var DD = datess.getDate() + '';
					console.log('调用了时间戳转日期')
					console.log(YY + MM + DD)
					var res = GetApi.splitdate(YY + MM + DD)
					return res
				},
			
		}
	}
</script>

<style>
	@import url("./SelectedGoods.css");
	.btn_color{
		background-color: #007AFF !important;
		color: #fff;
	}
	.btn_title{
		color: #000000;
	}
	.ls-box{
		width: 100%;
		height: 40px;
		border-radius: 5px;
		margin: 10px 0;
		line-height: 40px;
		font-size: 18px;
		text-align: center;
		color: #fff;
		background-color: #43a047;
		box-shadow: 0 7px 14px 0 rgba(59, 65, 94, 0.1), 0 3px 6px 0 rgba(0, 0, 0, 0.07);
	}
	.cu-form-group>input{
		text-align: left;
	}
	.cu-dialog{
		height: 70%;
	}
	.new-cu-dialog{
		height: 34%;
	}
	.btn_list{
		width: 100%;
		height: 40px;
		background-color: #07C160;
		color: #fff;
		text-align: center;
		line-height: 40px;
		border-radius: 5px;
		box-shadow: 0 2px 8px rgba(211, 209, 209, 0.75);
		margin: 7px 0;
		font-size: 16px;
	}
	.search{
		width: 100%;
		height: 40px;
		margin: 0 10px 0 0;
		/* background-color: #00B7B8; */
		border-radius: 5px;
		border: 1px solid #bcbbbb;
		
	}
	.search_span{
	width: 20%;
	height: 37px;
	background-color: #659AFF;
	color: #FFFFFF;
	text-align: center;
	display: inline-block;
	line-height: 37px;
	float: right;
	border-radius: 5px;
	}
	/* .search::before{
		content: '搜索'; */
	
		/* border-bottom-right-radius: 5px;
		border-top-right-radius: 5px; */
	/* } */
	.search>input{
		line-height: 40px;
		float: left;
		text-align: left;
		margin-left:5px ;
		margin-top: 6px;
	}
	.content{
		font-size: 16px;
	}
	.padding-xl{
		overflow-y: scroll;
	}
	.newbtn_list{
		margin: 0;
		margin-bottom: 15px;
	}
	.cu-form-group>input{
		font-size: 28upx;
	}
	.save{
		width: 100%;
		height: 40px;
		background-color: #007AFF;
		color: #fff;
		position: fixed;
		bottom: 0;
		left: 0;
		text-align: center;
		font-size: 18px;
		line-height: 40px;
	}
</style>

